package com.sun.commons;

import com.sun.commons.base.R;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import java.nio.file.AccessDeniedException;

@RestControllerAdvice
public class GlobalExceptionHandler {
    @ExceptionHandler(AccessDeniedException.class)
    public R error(AccessDeniedException e) {
        e.printStackTrace();
        return R.fail("权限不足");
    }

    @ExceptionHandler(Exception.class)
    public R error(Exception e) {
        e.printStackTrace();
        return R.fail(e.getMessage());
    }
}
